package icu.xuyijie.springbootlearning2.chapter4.openapi;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 徐一杰
 * @date 2025/03/06 16:17
 * @description 接口文档自动生成配置
 */
@Configuration
public class ApiDocConfig {

    @Bean
    public OpenAPI customOpenApi() {
        return new OpenAPI().info(
                new Info()
                        .title("我们的项目文档")
                        .description("测试生成接口文档，这是详细描述")
                        .version("1.0.0")
                        .contact(new Contact().url("https://xuyijie.icu").email("1119461672@qq.com"))
        );
    }

    @Bean
    public GroupedOpenApi allGroup() {
        return GroupedOpenApi.builder()
                .group("全部")
                .pathsToMatch("/**")
                .build();
    }

    @Bean
    public GroupedOpenApi firstGroup() {
        return GroupedOpenApi.builder()
                .group("第一个分组")
                .pathsToMatch("/mybatis/**")
                .build();
    }

    @Bean
    public GroupedOpenApi secondGroup() {
        return GroupedOpenApi.builder()
                .group("第二个分组")
                .pathsToMatch("/redis/**")
                .build();
    }

}
